package vip.youngboy.freejump.command;

import org.activiti.engine.impl.interceptor.Command;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;

public class EndProcessInstanceCommand implements Command<Void> {

    private String processId;

    public EndProcessInstanceCommand(String processId) {
        this.processId = processId;
    }

    @Override
    public Void execute(CommandContext commandContext) {
        ExecutionEntity executionEntity = commandContext.getExecutionEntityManager().findById(processId);
        executionEntity.setEnded(true);
        executionEntity.setActive(false);
        commandContext.getAgenda().planEndExecutionOperation(executionEntity);
        return null;
    }
}
